package service

import (
	"context"
	"github.com/redis/go-redis/v9"
	"month/videosvr/internal/models"
)

// todo 判断有没有点赞
func IsKey(key string) (interface{}, error) {
	return models.InitRedis(func(client *redis.Client) (interface{}, error) {
		return client.Exists(context.Background(), key).Result()
	})
}

// todo 点赞
func CreateLike(key string) (interface{}, error) {
	return models.InitRedis(func(client *redis.Client) (interface{}, error) {
		return client.Set(context.Background(), key, "点赞", -1).Result()
	})
}

// todo 取消点赞
func DelLike(key string) (interface{}, error) {
	return models.InitRedis(func(client *redis.Client) (interface{}, error) {
		return client.Del(context.Background(), key).Result()
	})
}
